package com.steakliu.shardingsphere.jdbc.generator;

import lombok.Getter;
import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;

import java.util.Locale;
import java.util.Properties;

/**
 * 功能说明： 自定义生成分布式id算法
 * <p>
 * Original @Author: steakliu-刘牌, 2022-07-25  16:25
 * <p>
 * Copyright (C)2020-2022  steakliu All rights reserved.
 */
@Getter
public final class CustomKeyGenerateAlgorithm implements KeyGenerateAlgorithm {

    private Properties props;

    @Override
    public Long generateKey() {
        return 5+System.currentTimeMillis();
    }

    @Override
    public Properties getProps() {
        return this.props;
    }

    @Override
    public String getType() {
        return "timeStamp".toUpperCase();
    }

    @Override
    public void init(final Properties props) {
        this.props = props;
    }
}
